import com.lzy.pojo.*;
import com.lzy.service.*;
import com.lzy.service.impl.*;
import org.junit.Test;

import java.util.List;
import java.util.Scanner;

public class test {
    @Test
    public void t1(){
        reservationService reservationService = new reservationServiceImpl();
        reservation reservation =new reservation("b",2,"H153");
        reservationService.insert(reservation);
    }
    @Test
    public void t2(){
        customerService busService =new customerServiceImpl();
        String num="Paul";
        customer select = busService.select(num);
        System.out.println(select);
    }
    @Test
    public void t3(){
        reservationService reservationService =new reservationServiceImpl();
        flightService flightService =new flightServiceImpl();
        String key = reservationService.selectKey("Paul");
        flight flight = flightService.select(key);
        System.out.println(flight.getFromCity()+flight.getArivCity());
    }
    @Test
    public void t4(){
        flightService flightService =new flightServiceImpl();
        flight flight = flightService.select("AL2895");
        if (flight.getNumSeats()>=flight.getNumAvail()) System.out.println("Plenty of seats on the flight");
        else System.out.println("The flight is fully seated");
    }
    @Test
    public void FinalTest(){
        flightService flightService=new flightServiceImpl();
        List<flight> flights = flightService.selectAll();
        for (flight flight : flights) {
            System.out.println(flight);
        }
    }
    @Test
    public void t5(){
        reservationService reservationService=new reservationServiceImpl();
        busService busService=new busServiceImpl();
        hotelsService hotelsService=new hotelsServiceImpl();
        flightService flightService=new flightServiceImpl();
        List<String> types = reservationService.selectTypes("a");
        List<String> keys = reservationService.selectKeys("a");
        System.out.println(types);
        System.out.println(keys);
        for (int i = 0; i < types.size(); i++) {
            if (types.get(i).equals("1")){
                flight flight = flightService.select(keys.get(i));
                System.out.println(flight);
            }
            if (types.get(i).equals("2")){
                hotels hotels = hotelsService.select(keys.get(i));
                System.out.println(hotels);
            }
        }
    }
    @Test
    public void t6(){
        reservationService reservationService=new reservationServiceImpl();
        reservationService.delete("a","H359");
    }
}
